package siga.controle;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.TreeSet;
import javax.swing.JComboBox;
import javax.swing.JPanel;

public class AlteraBox {

	public AlteraBox(){
	}
	
/*	public JComboBox cursosBox(JPanel panel, JComboBox cursosBox){
		try{
			String[] itens;
			String linha;
			TreeSet<String> set= new TreeSet<String>();
			FileReader fr = new FileReader("cadastroCursos.txt");
			BufferedReader br = new BufferedReader(fr);
			while((linha=br.readLine())!=null){
				String[] leitura;
				leitura = linha.split("\\|",2);
				set.add(leitura[0]);
			}
			linha = set.toString();
			String temp = "";
			for (int i = 1; i < linha.length() - 1; i++) {
				temp = temp + linha.charAt(i);
			}
			linha = temp;
			itens = linha.split(", ");
			cursosBox = new JComboBox(itens);
		} catch (Exception e) {} 
		cursosBox.setBounds(53, 22, 179, 25);
		panel.add(cursosBox);
		return cursosBox;
	} */
	
	public void disciplinasBox(JPanel panel, JComboBox disciplinasBox, String materia){
		try{
			String[] itens = null;
			String linha;
			TreeSet<String> set= new TreeSet<String>();
			FileReader fr = new FileReader("cadastroCursos.txt");
			BufferedReader br = new BufferedReader(fr);
			while((linha=br.readLine())!=null){
				String[] leitura;
				leitura = linha.split("\\|",2);
				if(leitura[0].equals(materia)){
					String d = leitura[1].substring(1, leitura[1].length()-1);
					String[] opcaoDis= d.split(", ");
					for(int i=0;i<opcaoDis.length;i++){
						String[] opD = opcaoDis[i].split("\\|");
						set.add(opD[0]);
					}
				}
			}
			linha = set.toString();
			String temp = linha.substring(1, linha.length()-1);
			itens = temp.split(", ");
			disciplinasBox = new JComboBox(itens);
		} catch (Exception e2) {}
		disciplinasBox.setBounds(82, 61, 172, 25);
		panel.add(disciplinasBox);
	}
}
